<?php
/**
 * Created by PhpStorm.
 * User: 王松
 * Time: 2017/7/6 15:38
 */

namespace App\Project\Printer;

use App\Models\MedicalPhysical;
use App\Models\MedicalRecord;

class PhysicalPrinter extends PrinterAbstract
{
    /**
     * @var \App\Models\MedicalRecord
     */
    protected $record;

    public function __construct(MedicalPhysical $physical, MedicalRecord $record)
    {
        $this->model = $physical;
        $this->record = $record;
    }

    public function tongue()
    {
        if ($this->record->isWestern() || !$this->model->tongue) {
            return '';
        }

        $print = [
            $this->fei('tongue', 'color', '舌色:'),
            $this->fei('tongue', 'status', '舌态:'),
            $this->fei('tongue', 'shape', '舌型:'),
            $this->fei('tongue', 'hypoglossis', '舌下脉络:'),
            $this->fei('tongue', 'tongue_coating', '舌苔:'),
            $this->fei('tongue', 'coating_color', '苔色:'),
            $this->fei('tongue', 'pulse_condition', '脉象:'),
            $this->fei('tongue', 'remark', '备注:'),
        ];

        return $this->getPrintStr('', $print);
    }

    public function examination()
    {
        $exa = $this->model->examination;

        if (!$exa) {
            return '';
        }

        $print = [
            $this->fe('examination', 'stature', '身高', 'CM'),
            $this->fe('examination', 'weight', '体重', 'KG'),
            $this->fe('examination', 'bmi', 'BMI'),
        ];

        if (isset($exa['blood_pressure']['low']) || isset($exa['blood_pressure']['high'])) {
            $print['pressure'] = '血压 ';

            if (isset($exa['blood_pressure']['high'])) {
                $print['pressure'] .= $exa['blood_pressure']['high'];
            }

            $print['pressure'] .= '/';

            if (isset($exa['blood_pressure']['low'])) {
                $print['pressure'] .= $exa['blood_pressure']['low'];
            }

            $print['pressure'] .= 'mmHg';
        }

        $print = array_merge($print, [
            $this->fe('examination', 'pulse', '脉搏', '次/分'),
            $this->fe('examination', 'waistline', '腰围', 'CM'),

        ]);

        $one = $this->getPrintStr('', $print);
        $two = $this->getPrintStr('', [
            $this->fe('examination', 'thyroid', "甲状腺"),
            $this->fe('examination', 'edema', '', '双下肢水肿'),
            $this->fe('examination', 'skin_rupture', '', '皮肤破溃'),
            $this->fe('examination', 'large_limb_profile', '', '肢大貌'),
        ]);

        return $one . $two;
    }

    public function cnExamination()
    {
        if ($this->record->isWestern() || !$this->model->cn_examination) {
            return '';
        }

        $print = [
            $this->fe('cn_examination', 'heart_rate', '心率:', '次/分钟'),
            $this->fe('cn_examination', 'heart_rhythm', '心律:'),
            $this->fe('cn_examination', 'heart_sound', '各瓣膜听诊区心音及杂音:'),
            $this->fe('cn_examination', 'liver_spleen_palpation', '肝脾触诊:'),
            $this->fe('cn_examination', 'thorax', '胸廓:'),
            $this->fe('cn_examination', 'lung_respiratory_sound', '肺部呼吸音:'),
            $this->fe('cn_examination', 'rale', '干湿啰音:'),
            $this->ft('physical.cn_examination', $this->fe('cn_examination', 'abdominal_mass'), '腹部有无包块:'),
            $this->fe('cn_examination', 'renal_area_percussion', '肝区叩诊:'),
            $this->fe('cn_examination', 'liver_area_percussion', '肾区叩诊:')
        ];

        return $this->getPrintStr('', $print);
    }

    public function other()
    {
        if (!$this->model->other) {
            return '';
        }
        $other_detail = $this->model->other;

        if ($other_detail['sfp'] != 0) {
            $print[] = $this->ft('physical.sfp', $this->fe('other', 'sfp'), '锁骨上脂肪垫');
        }
        if ($other_detail['buffalo_hump'] != 0) {
            $print[] = $this->ft('physical.buffalo_hump', $this->fe('other', 'buffalo_hump'), '水牛背');
        }
        if ($other_detail['acanthosis_nigricans'] != 0) {
            $print[] = $this->ft('physical.acanthosis_nigricans', $this->fe('other', 'acanthosis_nigricans'), '颈部黑棘皮症');
        }
        if ($other_detail['ecchymosis'] != 0) {
            $print[] = $this->ft('physical.ecchymosis', $this->fe('other', 'ecchymosis'), '瘀斑');
        }
        if ($other_detail['apl'] != 0) {
            $print[] = $this->ft('physical.apl', $this->fe('other', 'apl'), '腹部紫纹');
        }

        if (array_key_exists("pericardial_fricative",$other_detail))
        {
            if ($other_detail['pericardial_fricative'] != 0) {
                $print[] = $this->ft('physical.pericardial_fricative', $this->fe('other', 'pericardial_fricative'), '心包摩擦音');
            }
        }
        if (array_key_exists("pleural_fricative",$other_detail))
        {
            if ($other_detail['pleural_fricative'] != 0) {
                $print[] = $this->ft('physical.pleural_fricative', $this->fe('other', 'pleural_fricative'), '胸膜摩擦音');
            }
        }
        if (array_key_exists("murphy_character",$other_detail))
        {
            if ($other_detail['murphy_character'] != 0) {
                $print[] = $this->ft('physical.murphy_character', $this->fe('other', 'murphy_character'), '墨菲氏征');
            }
        }
        if (array_key_exists("moving_dullness",$other_detail))
        {
            if ($other_detail['moving_dullness'] != 0) {
                $print[] = $this->ft('physical.moving_dullness', $this->fe('other', 'moving_dullness'), '移动性浊音');
            }
        }







        $print = [
            $this->ft('physical.ankle_reflex', $this->fe('other', 'ankle_reflex'), '踝反射'),
            $this->ft('physical.btnp', $this->fe('other', 'btnp'), '大脚趾针刺痛觉'),
            $this->ft('physical.bttfvs', $this->fe('other', 'bttfvs'), '大脚趾音叉振动觉'),
            $this->ft('physical.10gnt', $this->fe('other', '10gnt'), '大脚趾10g尼龙丝触觉'),
        ];

        return $this->getPrintStr('', $print);
    }
}